var _tipTime;
// show tip
function showError(text, width, left, top) {
	var $errTip = $("#errTip");
	if (!width) {
		width = 300;
	}
	if ($errTip.size() == 0) {
		$errTip = $('<div id="errTip" class="alert-tip alert-err"><div></div><span></span></div>');
		$("body").append($errTip);

	}

	$errTip.show();

	$errTip.find("div").html(text);

	$errTip.width(width);
	$errTip.height($errTip.find("div").outerHeight());
	$errTip.find("div").width(width - 80);
	$errTip.find("span").width(width).height($errTip.find("div")
			.outerHeight());
	if (left || top) {
		$errTip.css("top", top);
		$errTip.css("left", left);
		$errTip.show();
	} else {		
		$errTip.centerShow();
	}
	clearTimeout(_tipTime);
	_tipTime = setTimeout(function() {
				$errTip.fadeOut("slow");
			}, 3000);

	return $errTip;
}

/* common function */
$.fn.extend({
	/**
	 * Show object in the center of window
	 */
	centerShow : function() {
		var $obj = $(this);
		var width = $obj.outerWidth(true);
		var height = $obj.outerHeight(true);
		if ($.browser.msie && $.browser.version == "6.0") {
			$obj.css({
						"position" : "absolute",
						"display" : "block",
						visibility : "visible"
					});
			var ie6Style = function() {
				$obj.css({
							"left" : Math
									.floor(($(window).width() - width)
											/ 2),
							"top" : Math
									.floor(($(window).height() - height)
											/ 2)
									+ $(window).scrollTop()
						});
			};
			ie6Style();
			$(window).resize(function() {
						ie6Style();
					}).scroll(function() {
						ie6Style();
					});
		} else {
			var $centerBox = $("#ffutil-center-box");
			if ($centerBox.size() == 0) {
				$centerBox = $("<div id='#ffutil-center-box' />");
				$centerBox.css({
							"position" : "fixed",
							"top" : "50%",
							"left" : "50%",
							"z-index" : 199
						});
				$("body").append($centerBox);
			}
			$centerBox.append($obj);
			$obj.css({
						"position" : "absolute",
						"left" : -Math.floor(width / 2),
						"top" : -Math.floor(height / 2),
						"display" : "block",
						visibility : "visible"
					});
		}
	},
	/**
	 * Show the object in the fixed position
	 * 
	 * @param {}
	 *            css
	 * @return {}
	 */
	posShow : function(css) {
		var obj = this;
		if ($.browser.msie && $.browser.version == "6.0") {
			$.extend(css, {
						"position" : "absolute",
						"display" : "block"
					});

			var tempCss = {};
			$.extend(tempCss, css);
			var height = $(obj).height();
			var setPos = function() {
				if (css["bottom"] != "undefined") {
					tempCss["bottom"] = parseInt(css["bottom"]);
					tempCss["zoom"] = 1;
					$(obj).css(tempCss);
					tempCss["zoom"] = 0;
				}
				$(obj).css(tempCss);
			};

			setPos();

			$(window).scroll(function() {
						setPos();
					}).resize(function() {
						setPos();
					});
		} else {
			$.extend(css, {
						"position" : "fixed",
						"display" : "block"
					});
			$(obj).css(css);
		}
		return this;
	}
});